-
Notifications
You must be signed in to change notification settings - Fork 175
✨ Feat: add Thin Waist address validation utilities and integrate into echo example #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
✨ Feat: add Thin Waist address validation utilities and integrate into echo example #811
Conversation
…tilities - Added `network_discover.py` to demonstrate Thin Waist address handling. - Introduced `address_validation.py` with functions for discovering available network interfaces, expanding wildcard addresses, and determining optimal binding addresses. - Included fallback mechanisms for environments lacking Thin Waist support.
- Replaced hardcoded listen address with `get_optimal_binding_address` for improved flexibility. - Imported address validation utilities in `echo.py` and updated `__init__.py` to include new functions.
- Introduced `test_echo_thin_waist.py` to validate the echo example's output for Thin Waist lines. - Added `test_address_validation.py` to cover functions for available interfaces, optimal binding addresses, and wildcard address expansion. - Included parameterized tests and environment checks for IPv6 support.
Hi @yashksaini-coder, ping me if you need help. |
Right now, I've created a draft PR to introduce the multiadd thin waist address. with integration to examples and tests, could you give me feedback on this approach. I've only done Phase 1 + 2 (partially) based on the issue #804 |
@@ -0,0 +1,51 @@ | |||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Trio we don't use asyncio (for uniformity in all code base)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okh got it
Can you modify
(venv) luca@r17:~/PNL_Launchpad_Curriculum/Libp2p/tmp/yashksaini-coder/py-libp2p$ python examples/echo/echo.py
I am 16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
Run this from the same folder in another console:
echo-demo -d /ip4/192.168.136.148/tcp/33387/p2p/16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
Waiting for incoming connections...
luca@r17:~/PNL_Launchpad_Curriculum/Libp2p/js-libp2p-examples/examples/js-libp2p-example-chat$ node src/listener.js
Listener ready, listening on:
/ip4/127.0.0.1/tcp/10333/p2p/12D3KooWCS6QSMEbtt77pWeB618W824aGVxhLhPEPaCUMGMvBhuk
/ip4/192.168.136.148/tcp/10333/p2p/12D3KooWCS6QSMEbtt77pWeB618W824aGVxhLhPEPaCUMGMvBhuk
/ip4/10.149.6.41/tcp/10333/p2p/12D3KooWCS6QSMEbtt77pWeB618W824aGVxhLhPEPaCUMGMvBhuk
echo.py
I am 16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
Listener ready, listening on:
/ip4/127.0.0.1/tcp/10333/p2p/16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
/ip4/192.168.136.148/tcp/10333/p2p/16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
/ip4/10.149.6.41/tcp/10333/p2p/16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
Run this from the same folder in another console:
echo-demo -d /ip4/192.168.136.148/tcp/33387/p2p/16Uiu2HAmRxqPcNXm9KAUAVKyQkpXF8c8r7S6jdpGK6K963w9Puwk
Waiting for incoming connections...
|
Got it exposing all available interfaces. @acul71 |
@yashksaini-coder Summary: yashksaini-coder's Thin Waist Address Validation PR🎯 Quick AssessmentOverall: Excellent foundation, needs minor refinements for JavaScript parity. Status: Phase 1 ✅ Complete, Phase 2 🔄 Partially Complete ✅ What's Working Well
🔧 Key Issues to Fix1. JavaScript Parity (High Priority)Problem: Echo shows only 1 address instead of multiple interfaces like JS libp2p. Current:
Target (like JS):
Fix: Use 2. Missing Loopback (High Priority)Problem: No 127.0.0.1 in output. Fix: Add loopback to addrs.append(Multiaddr(f"/ip4/127.0.0.1/{protocol}/{port}")) 3. Command Display (Medium Priority)Problem: Fix: Use first expanded address instead of 🚀 Quick Wins
📋 Action ItemsHigh Priority
Medium Priority
🏆 RecommendationApprove with minor revisions. The core implementation is solid - just needs these small tweaks to match JavaScript libp2p behavior. 🧪 Test Status✅ Unit Tests - All Passing
❌ Integration Test - FailingProblem: Test expects:
Current echo.py outputs:
Fix: Update integration test to match actual echo.py output format. 💡 Pro Tips
Bottom Line: Great work! Just need to show all interfaces like JavaScript libp2p does. 🚀 |
@acul71 got it this clears a lot, I will focus on the javascript libp2p interface showcase. |
What was wrong?
There was no integration for thin waist address validation.
Issue #804
How was it fixed?
Implements Phase 1 & partial Phase 2 of issue #804 by introducing Thin Waist Address Validation utilities and updating the
echo
example to use them, Using the multiaddr.libp2p/utils/address_validation.py
get_available_interfaces
get_optimal_binding_address
expand_wildcard_address
multiaddr.utils
libp2p/utils/__init__.py
examples/echo/echo.py
:/ip4/0.0.0.0/tcp/{port}
withget_optimal_binding_address
examples/advanced/network_discovery.py
tests/utils/test_address_validation.py
tests/examples/test_echo_thin_waist.py
(light integration)Why
Backward Compatibility
multiaddr.utils.get_thin_waist_addresses
/get_network_addrs
are unavailable, utilities fallback to conservative defaults.To-Do